<template>
  <div>
    <h3>Child 1</h3>
    <p>{{ label }}</p>
    <el-button @click="setChild2Label">设置Child2</el-button>
    <el-input v-model="lableSet"></el-input>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import $bus from "../../utils/mitt";
const label = ref("");
const lableSet = ref("");
const setLabel = (data: string) => {
  label.value = data;
};
const setChild2Label = () => {
  $bus.emit("setChild2Label", lableSet.value);
};
onMounted(() => {
  $bus.on("setChild1Label", setLabel);
});
</script>
